package com.now.printer.db;

import org.xutils.DbManager;
import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;
import org.xutils.ex.DbException;

import java.util.Date;
import java.util.List;

/**
 * Author: wyouflf
 * Date: 13-7-25
 * Time: 下午7:06
 */
@Table(name = "DocumentsTable", onCreated = "CREATE UNIQUE INDEX index_name ON DocumentsTable(id,name,imageId,lastTime,path,size)")
public class DocumentsTable {

    @Column(name = "id", isId = true)
    private long id;

    @Column(name = "name")
    private String name;

    @Column(name = "imageId")
    private int imageId;

    @Column(name = "lastTime")
    private String lastTime;

    @Column(name = "path")
    private String path;

    @Column(name = "size")
    private String size;


//    public List<Child> getChildren(DbManager db) throws DbException {
//        return db.selector(Child.class).where("parentId", "=", this.id).findAll();
//    }

    // 一对一
    //public Child getChild(DbManager db) throws DbException {
    //    return db.selector(Child.class).where("parentId", "=", this.id).findFirst();
    //}

    public int getImageId() {
        return imageId;
    }

    public void setImageId(int imageId) {
        this.imageId = imageId;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLastTime() {
        return lastTime;
    }

    public void setLastTime(String lastTime) {
        this.lastTime = lastTime;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    @Override
    public String toString() {
        return "Parent{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", lastTime='" + lastTime + '\'' +
                ", path=" + path +
                ", size=" + size +
                '}';
    }

    public boolean equals(Object obj) {
        if (obj instanceof DocumentsTable) {
            DocumentsTable u = (DocumentsTable) obj;
            return this.name==(u.name)
                    && this.id==(id)&& this.lastTime==(lastTime) && this.path==(path) && this.size==(size);
        }
        return super.equals(obj);
    }
}
